﻿using AnyCAD.Foundation;
using HelloWorld.WinForms.UI;
using System.Reflection;

namespace HelloWorld.WPF.Plugin
{
    public class HelloWorldCommand : Command
    {
        //Thread wpfThread;
        public HelloWorldCommand()
        {
            SetName("HelloWorld.WPF");
        }

        protected override bool Run(CommandContext ctx)
        {
            var form = new HelloForm();

            Button button = new Button();
            button.Text = "Open WPF Window";
            button.Dock = DockStyle.Top;
            button.Click += Button_Click;
            form.Controls.Add(button);

            /form.ShowDialog();
            //System.Windows.Forms.Application.Run(form);
            return true;
        }
        private void Button_Click(object? sender, EventArgs e)
        {
            // 创建并显示 WPF 窗口
            //var window = new HelloWindow();
            //window.Show(); // 或者使用 wpfWindow.ShowDialog() 显示模态窗口
        }
        //static void StartWpfApp()
        //{
        //    var window = new HelloWindow();
        //    var app = new System.Windows.Application();
        //    app.Run(window);
        //}
    }
}
